package com.ljh.SimpleTradingSystem.mybatis.mapper;

import com.ljh.SimpleTradingSystem.mybatis.entity.UserCollection;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface UserCollectionMapper {
    @Select("select * from userCollection where userId = #{userId}")
    List<UserCollection> selectByUserId(int userId);

    @Select("select * from userCollection where userId = #{userId} and goodsId = #{goodsId}")
    UserCollection selectByUserIdAndGoodsId(int userId, int goodsId);

    @Insert("insert into userCollection(goodsId, userId)" +
            "values (#{goodsId}, #{userId})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insert(UserCollection userCollection);

    @Delete("delete userCollection goods where userId = #{userId} and goodsId = #{goodsId}")
    void deleteByUserIdAndGoodsId(int userId, int goodsId);
}
